﻿
@{
    ViewData["Title"] = "添加学生";
}

<h2>添加学生</h2>

<form action="/Students/Create" method="post" class="form-horizontal">
    @Html.AntiForgeryToken()
    <div class="form-group">
        <label for="name" class="col-sm-2 control-label">名称</label>
        <div class="col-sm-5">
            <input type="text" class="form-control" name="name" id="name" placeholder="名称">
        </div>
    </div>
    <div class="form-group">
        <label for="birthday" class="col-sm-2 control-label">生日</label>
        <div class="col-sm-3">
            <input type="datetime" class="form-control" name="birthday" id="birthday" placeholder="生日">
        </div>
    </div>
    <div class="form-group">
        <label for="introduction" class="col-sm-2 control-label">介绍</label>
        <div class="col-sm-5">
            <textarea name="introduction" id="introduction" class="form-control"></textarea>
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="btn btn-default">提交</button>
            <button type="button" class="btn btn-default">Ajax提交</button>
        </div>
    </div>
</form>
@section  Scripts{ 
    <script>
        $("#birthday").datepicker({
            language: "zh-CN",
            autoclose: true,//选中之后自动隐藏日期选择框
            clearBtn: true,//清除按钮
            todayBtn: true,//今日按钮
            format: "yyyy-mm-dd"//日期格式，详见 http://bootstrap-datepicker.readthedocs.org/en/release/options.html#format
        });
        $("form button").on('click', function () {
            $.ajax({
                type: 'POST',
                data: $('form').serializeArray(),
                url: $('form').attr("action"),
                //headers: { '__RequestVerificationToken': $('@@Html.AntiForgeryToken()').val()},
                success: function () {

                    location.href = "/Students/Index";
                }
            });
        })
    </script>
}
